package cn.source.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.GkMemberSetting;
import cn.source.system.service.IGkMemberSettingService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 用户偏好设置Controller
 *
 * @author sourcebyte.vip
 * @date 2025-05-02
 */
@RestController
@RequestMapping("/system/gkMemberSetting")
public class GkMemberSettingController extends BaseController
{
    @Autowired
    private IGkMemberSettingService gkMemberSettingService;

    /**
     * 查询用户偏好设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:gkMemberSetting:list')")
    @GetMapping("/list")
    public TableDataInfo list(GkMemberSetting gkMemberSetting)
    {
        startPage();
        List<GkMemberSetting> list = gkMemberSettingService.selectGkMemberSettingList(gkMemberSetting);
        return getDataTable(list);
    }

    /**
     * 获取用户偏好设置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gkMemberSettingService.selectGkMemberSettingById(id));
    }

    /**
     * 新增用户偏好设置
     */
    @PreAuthorize("@ss.hasPermi('system:gkMemberSetting:add')")
    @Log(title = "用户偏好设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GkMemberSetting gkMemberSetting)
    {
        return toAjax(gkMemberSettingService.insertGkMemberSetting(gkMemberSetting));
    }

    /**
     * 修改用户偏好设置
     */
    @PreAuthorize("@ss.hasPermi('system:gkMemberSetting:edit')")
    @Log(title = "用户偏好设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GkMemberSetting gkMemberSetting)
    {
        return toAjax(gkMemberSettingService.updateGkMemberSetting(gkMemberSetting));
    }

    /**
     * 删除用户偏好设置
     */
    @PreAuthorize("@ss.hasPermi('system:gkMemberSetting:remove')")
    @Log(title = "用户偏好设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gkMemberSettingService.deleteGkMemberSettingByIds(ids));
    }

    /**
     * 导出用户偏好设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:gkMemberSetting:export')")
    @Log(title = "用户偏好设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GkMemberSetting gkMemberSetting)
    {
        List<GkMemberSetting> list = gkMemberSettingService.selectGkMemberSettingList(gkMemberSetting);
        ExcelUtil<GkMemberSetting> util = new ExcelUtil<GkMemberSetting>(GkMemberSetting.class);
        util.exportExcel(response, list, "用户偏好设置数据");
    }
}
